<div class="content">
  <h1 mat-dialog-title class="title">编辑用户</h1>
  <form  #userForm="ngForm">
    <div mat-dialog-content class="user-form">
    <mat-form-field appearance="standard">
      <mat-label>用户名</mat-label>
      <input matInput required [(ngModel)]="user.username" name="username" pattern="^[A-Za-z]+\w{3,20}">
      <mat-error *ngIf="messages.userName">{{ messages.userName }}</mat-error>
    </mat-form-field>

      <mat-form-field appearance="standard">
        <mat-label>真实姓名</mat-label>
        <input matInput required [(ngModel)]="user.realName" name="realName">
        <mat-error *ngIf="messages.realName">{{ messages.realName }}</mat-error>
      </mat-form-field>


      <mat-form-field appearance="standard">
        <mat-label>电话</mat-label>
        <input matInput [(ngModel)]="user.phone" name="phone" pattern="^(((\+86)|(86))?1[34578]\d{9})$" >
        <mat-error *ngIf="messages.phone">{{ messages.phone }}</mat-error>
      </mat-form-field>

      <mat-form-field appearance="standard">
        <mat-label>邮箱</mat-label>
        <input matInput [(ngModel)]="user.email" name="email" pattern="^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$">
        <mat-error *ngIf="messages.email">{{ messages.email }}</mat-error>
      </mat-form-field>

      <mat-form-field appearance="standard">
        <mat-label>地址</mat-label>
        <input matInput [(ngModel)]="user.address" name="address" >
        <!--<mat-error *ngIf="messages.address">{{ messages.address }}</mat-error>-->
      </mat-form-field>

      <mat-form-field appearance="standard">
        <mat-label>所属部门</mat-label>
        <mat-select placeholder="所属部门" [(value)]="user.departmentId" [(ngModel)]="user.departmentId" name="departmentId">
          <mat-option *ngFor="let department of departments" [value]="department.id">
            {{department.departName}}
          </mat-option>
        </mat-select>
        <mat-error *ngIf="false"></mat-error>
      </mat-form-field>


</div>
  <div mat-dialog-actions class="buttons">
    <button mat-button (click)="onSubmit()">确认</button>
    <button mat-button [mat-dialog-close] cdkFocusInitial>取消</button>
  </div>
  </form>
</div>
